package com.haiyi.software.app.basic;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.MediaStore;

import com.haiyi.software.app.HiChat;
import com.haiyi.software.app.MainApplication;

public abstract class HiChatCameraBasic extends HiChatImageBasic {

	private final static String TAG = "HiChatCameraBasic";

	// protected String CameraFileSrc;

	// protected JsonObject jsonReturnCamera = null;

	protected Uri CameraFileUri;

	protected void takeCaptureImage() {

		String CameraFileName;

		CameraFileName = MainApplication.getInstance().getMineUserInfo()
				.getUid()
				+ "_" + System.currentTimeMillis() + ".jpg";

		imageFileSrc = MainApplication.getInstance().getAppImageDirectory()
				+ "/" + CameraFileName;

		String imgSrc = "file://"
				+ MainApplication.getInstance().getAppImageDirectory() + "/"
				+ CameraFileName;

		CameraFileUri = Uri.parse(imgSrc);

		Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
		intent.putExtra(MediaStore.EXTRA_OUTPUT, CameraFileUri);
		startActivityForResult(intent, HiChat.SHOW_SUB_GET_CAMERA);
	}

	protected void cropImageUri() {
		Intent intent = new Intent("com.android.camera.action.CROP");
		intent.setDataAndType(CameraFileUri, "image/*");
		intent.putExtra("crop", "true");
		// intent.putExtra("aspectX", 1);
		// intent.putExtra("aspectY", 1);
		// intent.putExtra("outputX", outputX);
		// intent.putExtra("outputY", outputY);
		intent.putExtra("scale", true);
		intent.putExtra(MediaStore.EXTRA_OUTPUT, CameraFileUri);
		intent.putExtra("return-data", false);
		intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
		intent.putExtra("noFaceDetection", true); // no face detection
		startActivityForResult(intent, HiChat.SHOW_SUB_GET_CAMERA_EDIT);
	}

}
